<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    * {
      margin: 0;
      padding: 0;
      font-family:cursive;
    }
    body {
      display: flex;
    }
    .container {
      position:fixed;
      top: 0;
      left: 0;
      width: 100vw;
      padding: 0 100px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      /* box-shadow: 0 2px 4px gray; */
      box-sizing: border-box;
      transition: .6s;
    }
    .container.sticky {
      justify-content: flex-end;
      padding: 5px 100px;
      background-color:#fff;
      box-shadow: 0 2px 4px gray;
    }
    .container.sticky a {
      display: none;
    }
    .container.sticky ul  li{
      color: gray;
      text-shadow: 4px 4px #eee;
    }
    .container a {
      text-decoration: none;
      color: #eee;
      font-style: italic;
      font-size: 28px
    }
    .container ul {
      list-style: none;
      /* width: 100%; */
      display: flex;
      /* justify-content: flex-end; */
      line-height: 38px;
      height: 40px;
      transform: skew(-20deg);
    }
    .container ul li {
      position: relative;
      padding: 0 15px;
      color: #eee;
      text-shadow: 4px 4px gray;
      cursor: pointer;
      transition:all .8s;
      border-radius: 10% 0;
    }
    /* .container ul li span {
      position:absolute;
      bottom: 0;
      left: 50%;
      width: 0%;
      height: 2px;
      background: #f9ca24;
      transform: translateX(-50%);
      border-radius: 10px;
      opacity:0;
      transition:width .6s;
    } */
    .container ul li:hover {
      /* background-color:#c7ecee; */
      text-shadow: none;
      color: #000;
    }
    /* .container ul li:hover span{
      width: 30%;
      opacity: 1;
    } */
    .box {
      width: 100vw;
      height: 130vh;
    }
    .box img {
      display: block;
      width: 100%;
      height: 100%;
    }
  </style>
</head>
<body>
  <div class="container">
    <a href="#">Glasses</a>
    <ul>
     <li>HOME
       <span></span></li>
     <li>USER
       <span></span></li>
     <li>MINE
       <span></span></li>
     <li>MORE
       <span></span></li>
    </ul>
  </div>
  <div class="box">
    <img src="https://z3.ax1x.com/2021/06/01/2u2mcV.jpg" alt="背景图">
  </div>
</body>
<script>
  window.addEventListener('scroll',()=>{
    let header = document.querySelector('div')
    header.classList.toggle('sticky',window.scrollY > 0)
  })
</script>
</html>